{extend name="layout:base" /}{block name="content"}
 <?php
$global=isSupperManagerForSession();
 ?>
<section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
         <span data-url="/admin/dep/lists" onclick="ContentLoadGo('/admin/dep/lists')">部门管理</span>
         </div>
      </section>
   
      <section style="margin-top:10px;margin-left:auto;margin-right:auto;">
      <select name="ser_key" id="ser_key" class="select" >
       <option value="depname" <?php if($request['ser_key']=="depname"){echo 'selected';} ?>>部门名称</option>
       <option value="id" <?php if($request['ser_key']=="id"){echo 'selected';} ?>>部门ID</option>
      </select>
      <input type="text" class="textbox" name="ser_val" id="ser_val" value="<?php echo $request['ser_val']; ?>" placeholder=""/>
       
      <input type="button" value="搜索" class="group_btn research" id="resource" page="1" />
        <?php
	    if( ( in_array(40000,$ruleLists) || $global==1) )
		{
    	?>
      <input type="button" power="40000" value="添加" class="group_btn add fr" />
      	<?php
      	}
		?>
      <br style="clear:both;width:0px;height:0px;">
     </section>
 
       
   
<table class="table" style="margin-top:10px;">

<tr>
<th><input id="all" type="checkbox"></th>
<th>ID</th>
<th>级别</th>
<th>部门名称</th>

<th >操作</th>
</tr>

<?php 
foreach($lists['data'] as $key=>$val)
{
?>
<tr data-id="<?php echo $val['id']; ?>">

<td style="text-align:center;width:20px;">
<input type="checkbox" value="<?=$val['id']?>" class="checkBoxInput" name="checked[]" /></td>
<td style="width:100px;"><?php echo $val['id'];?></td>
<td style="width:120px;">顶级部门</td>
<td style="width:120px;"><?php echo $val['depname'];?></td>





<td style="text-align:right;width:120px;">

<input type="button" value="二级部门" class="link_btn nextDep"/>
        <?php
	    if( ( in_array(41000,$ruleLists) || $global==1) )
		{
    	?>
<input type="button" power="41000" value="修改" class="link_btn edit"/>
      	<?php
      	}
		?>
        <?php
	    if( ( in_array(42000,$ruleLists) || $global==1) )
		{
    	?>
<input type="button" power="42000" value="删除" class="link_btn del"/>
      	<?php
      	}
		?>

</td>
</tr>
      <?php
      }
	  ?>
</table>

      <script type="text/javascript">
      
      function myResearch(){
		   var url="/admin/dep/lists";
		   var ser_key =$("#ser_key").val();
		   var ser_val =$("#ser_val").val();
		 
		
		   var page=$("#cpage").val();
		   var param={
				   ser_key:ser_key, 
				   ser_val:ser_val, 
				
				  
				   page:page,
		   };
		   ContentLoadGo(url,param);
	   }
     
      
           $(function(){
        	   //设置搜索栏
        	   $(".research").click(function(){
        		   var page =$(this).attr("page");
        		   $("#cpage").val(page);
        		   myResearch();
        		   
        	   });
        	   
        	   //删除项
        	   $('.del').click(function(){
        		   var that =this;
        		   var url="/admin/dep/delData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要删除吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   
            				   $(that).parent().parent().remove();
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi(data.msg);
            			   }
            		   });
        			   
        		   });
        	   });
        	   
        	 //启用
        	   $('.qy').click(function(){
        		   var that =this;
        		   var url="/admin/dep/qyData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要启用吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   $(that).val("禁用");
            				  
            				 
            				  $(that).parent().parent().find(".dataStat").html("正常");
            				   $(that).removeClass("qy");
            				   $(that).addClass("jy");
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	 
        	 
        	 //二级部门
        	   $('.nextDep').click(function(){
        		   var that =this;
        		   var url="/admin/dep2/lists";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   pid:id
        		   };
        		   ContentGet(url,param);
        	   });
        	 
        	   //禁用
        	   $('.jy').click(function(){
        		   var that =this;
        		   var url="/admin/dep/jyData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   cofirmsss_tishi(1,'您确定要禁用吗?',function(id){
        			 
        			   AjaxRequest(url,param,function(data){
            			   if(data.err==0)
            			   {
            				   SuccessTiShi("操作成功");
            				   $(that).val("启用");
            				   
            				   $(that).parent().parent().find(".dataStat").html("禁用");
            				   $(that).removeClass("jy");
            				   $(that).addClass("qy");
            				   myResearch();
            			   }
            			   else
            			   {
            				   ErrTiShi("操作失败");
            			   }
            		   });
        			   
        		   });
        	   });
        	   //编辑项
        	   $(".edit").click(function(){
        		   var that =this;
        		   var url="/admin/dep/editData";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   MyContentLoad(url,param);
        				 
        				
        			 //弹出：确认按钮
        			
        	   });

        	   $(".resetPwd").click(function(){
        		   var that =this;
        		   var url="/admin/dep/resetPwd";
        		   var id=$(that).parent().parent().attr('data-id');
        		   var param={
        				   id:id
        		   };
        		   MyContentLoad(url,param);
        				 
        				
        			 //弹出：确认按钮
        			
        	   });
        	   
        	   
        	   
        	   //编辑项
        	   $(".add").click(function(){
        		   
        		   var that =this;
        		   var url="/admin/dep/addData";
        		   var param={};
        		   MyContentLoad(url,param);
        			 //弹出：确认按钮
        			
        	   });
        	   
        	   //导航
         	   $(".topBannerItem").click(function(){
         		   
         		   var attArr = $(this).attr();
             	   goToSelfLink(attArr);
             	   
         			
         	   });
  			   //全选
  		
  				$("#all").click(function(){   
			    	if(this.checked){   
			        	$(".checkBoxInput").attr("checked", true);  
			        	$(".checkBoxInput").prop("checked", true);  
			    	}else{   
						$(".checkBoxInput").attr("checked", false);
						$(".checkBoxInput").prop("checked", false);
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  			   
  			
           });
           
	  </script>
	  {/block}
   